package br.com.spread.svnutils;

import java.lang.reflect.Field;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamConverter;
import com.thoughtworks.xstream.converters.extended.ToAttributedValueConverter;

@XStreamAlias("path")
@XStreamConverter(value = ToAttributedValueConverter.class, strings = { "value" })

/**
 * 
 * @author josen
 *
 */
public class Path {

	@XStreamAlias("kind")
	@XStreamAsAttribute
	String kind;

	@XStreamAlias("action")
	@XStreamAsAttribute
	String action;

	@XStreamAlias("prop-mods")
	@XStreamAsAttribute
	String propmods;

	@XStreamAlias("text-mods")
	@XStreamAsAttribute
	String textmods;

	String value;

	public Path(String kind, String action, String value){
		this.kind = kind;
		this.action = action;
		this.value = value;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();

		Class<?> thisClass = null;
		try {
			thisClass = Class.forName(this.getClass().getName());

			Field[] aClassFields = thisClass.getDeclaredFields();
			sb.append(this.getClass().getSimpleName() + " [ ");
			for (Field f : aClassFields) {
				String fName = f.getName();
				sb.append(fName + ":" + f.get(this) + ", ");
			}
			sb.append("]");
		} catch (Exception e) {
			e.printStackTrace();
		}

		return sb.toString();
	}
}
